package cn.itsource.hrm.controller;

import cn.itsource.hrm.dto.SendSMSCodeDTO;
import cn.itsource.hrm.service.IVerifyCodeService;
import cn.itsource.hrm.util.AjaxResult;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifycodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    //短信验证码
    @PostMapping("/sendSmsCode")
    public AjaxResult sendSMSCode(@RequestBody @Valid SendSMSCodeDTO dto){
        verifyCodeService.sendSMSCode(dto);
        return AjaxResult.me();
    }
    //图片验证码
    @GetMapping("/imageCode/{key}")
    public AjaxResult createImageCode(@PathVariable("key")String key){
        String base64 = verifyCodeService.createImageCode(key);
        return AjaxResult.me().setResultObj(base64);
    }
}
